package com.shop.cereshop.app.param.index;

import cn.hutool.core.util.StrUtil;
import com.shop.cereshop.commons.config.RsaProperties;
import com.shop.cereshop.commons.utils.RsaUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;

/**
 * @author lx
 * @version 1.0
 * @description: TODO
 * @date 2025/8/1 12:12
 */
@Data
@Accessors(chain = true)
@ApiModel(value = "LoginDTO", description = "登录请求DTO")
@Slf4j
public class LoginDTO {

    @ApiModelProperty(value = "验证码", required = true)
    private String verificationCode;

    @ApiModelProperty(value = "手机号/uuid(需要加密)", required = true)
    private String phone;

    @ApiModelProperty(value = "访问终端 0-未知 1-APP 2-微信小程序 3-H5 4-支付宝小程序 5-PC")
    private Integer terminal;

    @ApiModelProperty(value = "渠道id")
    private String channelCode;

    public LoginDTO decrypt() throws Exception {
        LoginDTO res = this;
        try {
            res.setPhone(RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, this.phone));
        } catch (Exception e) {
//            e.printStackTrace();
            log.error("解密失败");
        }
        return res;
    }
}
